package io.modifier.basic.compose.hooks.time

import androidx.compose.runtime.Composable
import io.modifier.basic.compose.hooks.useEffect
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
import kotlinx.coroutines.delay

/** 定时一段时间后执行的任务 **/
@Composable
fun useTimeout(delay: Duration = 1.seconds, block: () -> Unit) {
    useEffect {
        delay(delay)
        block()
    }
}
